﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Galunggung
{
    public class Helper
    {
        public static List<string> GenerateAutoMacAddress()
        {
            List<string> list = new List<string>();
            Random random = new Random();

            for (int i = 0; i < 6; i++)
            {
                int num = random.Next(0,255);
                string s = num.ToString("X");

                if(s.Length==1)
                    list.Add("0" + num.ToString("X"));                
                else
                    list.Add(num.ToString("X"));
            }
            return list;
        }

        // credit from
        // http://stackoverflow.com/questions/223832/check-a-string-to-see-if-all-characters-are-hexadecimal-values
        public static bool IsValidHexString(IEnumerable<char> hexString)
        {
            return hexString.Select(currentCharacter =>
                        (currentCharacter >= '0' && currentCharacter <= '9') ||
                        (currentCharacter >= 'a' && currentCharacter <= 'f') ||
                        (currentCharacter >= 'A' && currentCharacter <= 'F')).All(isHexCharacter => isHexCharacter);
        }


    }
}
